#!/bin/bash
function get_current_commit_id()
{
    cd $source_dir/arkcompiler/ets_runtime
    js_runtime_current_commit_id=`git rev-parse --short HEAD`
    js_runtime_current_commit_href="https://gitee.com/openharmony/arkcompiler_ets_runtime/commit/`git rev-parse HEAD`"
    cd $source_dir/arkcompiler/runtime_core
    runtime_core_current_commit_id=`git rev-parse --short HEAD`
    runtime_core_current_commit_href="https://gitee.com/openharmony/arkcompiler_runtime_core/commit/`git rev-parse HEAD`"
    cd $source_dir/arkcompiler/ets_frontend
    ts2abc_current_commit_id=`git rev-parse --short HEAD`
    ts2abc_current_commit_href="https://gitee.com/openharmony/arkcompiler_ets_frontend/commit/`git rev-parse HEAD`"

    cd $test_dir
    sed -i "s#js_runtime_current_commit_href#$js_runtime_current_commit_href#" build_commit_table.html
    sed -i "s#js_runtime_current_commit_id#$js_runtime_current_commit_id#" build_commit_table.html
    sed -i "s#runtime_core_current_commit_href#$runtime_core_current_commit_href#" build_commit_table.html
    sed -i "s#runtime_core_current_commit_id#$runtime_core_current_commit_id#" build_commit_table.html
    sed -i "s#ts2abc_current_commit_href#$ts2abc_current_commit_href#" build_commit_table.html
    sed -i "s#ts2abc_current_commit_id#$ts2abc_current_commit_id#" build_commit_table.html
}

function run_test_sync_code()
{
    cp $test_dir/build_commit_table.template $test_dir/build_commit_table.html
    # sync code
    cd $source_dir
    echo 123456 | sudo -S rm -rf arkcompiler/ets_frontend/ts2panda/node_modules
    echo 123456 | sudo -S repo forall -c 'git clean -ffdx'
    echo 123456 | sudo -S repo forall -c 'git reset --hard HEAD'
    repo sync --force-sync -c --jobs 32
    repo forall -c 'git lfs pull'
    repo start master --all
    ./build/prebuilts_download.sh
}

function get_UT_result()
{
    cp $test_dir/UTreport.html  $test_dir/UTreport2.html 
    if grep -q "build  successful"  $log_dir/UT_${time_stamp}_releaseUT.log; then
        sed -i 's/release_UT_ID/OK/g' $test_dir/UTreport2.html 
    else
        sed -i 's/release_UT_ID/FAIL/g' $test_dir/UTreport2.html 
    fi
    if grep -q "build  successful"  $log_dir/UT_${time_stamp}_debugUT.log; then
        sed -i 's/debugger_UT_ID/OK/g' $test_dir/UTreport2.html 
    else
        sed -i 's/debugger_UT_ID/FAIL/g' $test_dir/UTreport2.html 
    fi
    cat $test_dir/UTreport2.html >> $test_dir/test_report.html
    rm $test_dir/UTreport2.html
}

function run_test_release()
{
    cd $source_dir
    echo 123456 | sudo -S rm -rf out/rk3568
    ./build.sh --product-name rk3568 --build-target ets_frontend_build --build-target ark_js_host_linux_tools_packages > $log_dir/rk3568_build_release.log
    cd $source_dir/out/rk3568/clang_x64/arkcompiler/ets_frontend/build
    mkdir deps
    cp $source_dir/third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz $source_dir/out/rk3568/clang_x64/arkcompiler/ets_frontend/build/deps/
    npm install 
    # python $test_dir/runUT.py
    cd $source_dir
    cd arkcompiler/ets_frontend
    # aot es2panda
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler --ark-aot > $log_dir/test262_${time_stamp}_aot_release.log
    # asmint es2panda
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler > $log_dir/test262_${time_stamp}_asmint_release.log
    # ts2abc c release
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads=128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/thirdparty/zlib:../../out/rk3568/clang_x64/thirdparty/icu:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/build/src/index.js --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc > $log_dir/test262_${time_stamp}_cint_release.log 
    # es2panda c release
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ark:../../out/rk3568/clang_x64/thirdparty/zlib:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/icu:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda > $log_dir/test262_${time_stamp}_cint_es2panda_release.log

    
    #benchmark
    cd $source_dir
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_aot_x64 --all -p r -f es2abc --timeout 2400 &> $log_dir/benchmark_${time_stamp}_aot_x64.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_asmint_x64 --all -p r --tool asmint --timeout 2400 &> $log_dir/benchmark_${time_stamp}_asmint_x64.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_es2abc --all -p r -f es2abc --tool asmint --timeout 2400 &> $log_dir/benchmark_${time_stamp}_es2abc.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_es2abc_aot_no_type --all -p r -f es2abc --timeout 2400 &> $log_dir/benchmark_${time_stamp}_es2abc_aot_no_type.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_has_opt_v8 --all -p r --tool node --timeout 2400 &> $log_dir/benchmark_${time_stamp}_has_opt_v8.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_no_opt_v8 --all -p r --tool node --frontend-args="--no-opt" --timeout 2400 &> $log_dir/benchmark_${time_stamp}_no_opt_v8.log &
    # python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_hermes --all -p r --tool hermes --timeout 2400 &> $log_dir/benchmark_${time_stamp}_hermes.log &
    $test_dir/hermes.sh &> $log_dir/benchmark_${time_stamp}_hermes.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_qjs --all -p r --tool qjs --timeout 2400 &> $log_dir/benchmark_${time_stamp}_qjs.log &
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_int --all -p r -f es2abc --tool int --timeout 2400 &> $log_dir/benchmark_${time_stamp}_int.log &
    /mnt/data/zwx1072417/ArkDaily/openharmony/run/run_pgo.sh 

    #benchmark_ts
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/node --all -p r --tool node --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_v8_x64.log
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/js --all -p r --tool asmint --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_asmint_x64.log
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/ts --all -p r --bt --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_aot_type_x64.log
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/ts --all -p r --aot-args="--enable-type-lowering=false" --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_aot_no_type_x64.log
    #es2abc-asmint(js-x64)
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/js --all -p r -f es2abc --tool asmint --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_es2abc_asmint_x64.log
    #es2abc-aot-type(ts-x64)
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/ts --all -p r --bt -f es2abc --frontend-args="--module --type-extractor" --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_es2abc_aot_type_x64.log
    #es2abc-aot-no-type(ts-x64)
    # python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/ts --all -p r -f es2abc --frontend-args="--module" --aot-args="--enable-type-lowering=false" --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_es2abc_aot_no_type_x64.log
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_ts/ts --all -p r -f es2abc --frontend-args="--module" --timeout 2400 &> $log_dir/benchmark_ts_${time_stamp}_es2abc_aot_no_type_x64.log
    # cd /mnt/data/zwx1072417/ArkDaily/workload/ark-workload/
    # /mnt/data/zwx1072417/ArkDaily/workload/ark-workload/run_swift_test_hl.sh
    # /mnt/data/zwx1072417/ArkDaily/workload/ark-workload/run_pgo.sh &> $log_dir/workload_pgo.log
}

function run_test_debug()
{
    cd $source_dir
    # speed up for debug test
    # sed -i 's/\([^a-z]\)-O0/\1-O1/' arkcompiler/ets_runtime/BUILD.gn
    rm -rf out/rk3568
    ./build.sh --product-name rk3568 --build-target ets_frontend_build --build-target ark_js_host_linux_tools_packages --gn-args is_debug=true >$log_dir/rk3568_build_debug.log
    cd arkcompiler/ets_frontend
    # aot
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler --ark-aot > $log_dir/test262_${time_stamp}_aot_debug.log
    # asmint
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir ../../out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler > $log_dir/test262_${time_stamp}_asmint_debug.log
    #ts2abc c debug
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 500000 --libs-dir ../../out/rk3568/clang_x64/arkcompiler/ets_runtime:../../out/rk3568/clang_x64/thirdparty/zlib:../../out/rk3568/clang_x64/thirdparty/icu:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib --ark-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_js_vm --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda > $log_dir/test262_${time_stamp}_cint_debug.log
}

function run_test_arm64()
{
    # aot_arm64,asmint_arm64
    # Turn off the detection switch
    # cd $source_dir/arkcompiler/ets_runtime
    # cp $source_dir/close_check.patch ./
    # git apply --reject close_check.patch
    # reset_code()
    ./build.sh --product-name rk3568 --build-target ark_js_host_unittest > $log_dir/UT_${time_stamp}_releaseUT.log
    ./build.sh --product-name rk3568 --build-target ark_js_host_unittest --gn-args is_debug=true > $log_dir/UT_${time_stamp}_debugUT.log
    # 262.patch
    # cd $source_dir/arkcompiler/ets_frontend
    # cp $source_dir/262.patch ./
    # git apply --reject 262.patch

    # cd foundation/bundlemanager/bundle_framework/services
    # cp $source_dir/bundlemgr.diff ./
    # git apply --reject bundlemgr.diff


    # cd $source_dir/arkcompiler/ets_runtime
    # cp $source_dir/ets_runtime.diff ./
    # git apply --reject ets_runtime.diff

    # cd $source_dir/arkcompiler/runtime_core
    # cp $source_dir/runtime_core.diff ./
    # git apply --reject runtime_core.diff

    cd $source_dir/arkcompiler/ets_runtime/
    cp /mnt/data/zwx1072417/ArkDaily/openharmony/patch/arm64.patch ./
    echo 123456 | sudo -S git apply --reject arm64.patch

    cd $source_dir/arkcompiler/runtime_core/
    cp /mnt/data/zwx1072417/ArkDaily/openharmony/patch/runtime_core.patch ./
    echo 123456 | sudo -S git apply --reject runtime_core.patch
    
    # set timeout for 262 test
    # sed -i 's/DEFAULT_TIMEOUT = 6000/DEFAULT_TIMEOUT = 60000/g'  $source_dir/arkcompiler/ets_frontend/test262/config.py
    # compile
    cd $source_dir
    rm -rf out/rk3568
    ./build.sh --product-name rk3568 --gn-args use_musl=true --build-target musl_libs --build-target ets_frontend_build --build-target ark_js_packages --build-target ark_js_host_linux_tools_packages --target-cpu arm64 > $log_dir/rk3568_arm64.log
    # for qemu
    # python3 $source_dir/arkcompiler/ets_runtime/test/runtest.py -p r test/aottest/add --npm
    cd $source_dir/out/rk3568/clang_x64/arkcompiler/ets_frontend/build/
    mkdir deps
    cp $source_dir/third_party/typescript/build_package/ohos-typescript-4.2.3-r2.tgz $source_dir/out/rk3568/clang_x64/arkcompiler/ets_frontend/build/deps/
    npm install 
    cd $source_dir
    echo 123456 | sudo -S cp /mnt/data/zwx1072417/ArkDaily/openharmony/code/out/rk3568/common/common/libc/ld-musl-aarch64.so.1 /lib
    # cp -f $test_dir/runtest.py $source_dir/arkcompiler/ets_runtime/test
    cd arkcompiler/ets_frontend
    # aot
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir=../../out/rk3568/arkcompiler/ets_runtime/:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos/:../../out/rk3568/utils/utils_base/:../../out/rk3568/thirdparty/icu:../../out/rk3568/thirdparty/zlib:../../out/rk3568/securec/thirdparty_bounds_checking_function:../../out/rk3568/hiviewdfx/faultloggerd:../../out/rk3568/thirdparty/bounds_checking_function:../../out/rk3568/hiviewdfx/hilog_native:../../out/rk3568/startup/init:../../out/rk3568/thirdparty/cjson:../../out/rk3568/lib.unstripped/common/dsoftbus:../../out/rk3568/security/selinux:../../out/rk3568/hiviewdfx/hitrace_native/:../../out/rk3568/lib.unstripped/communication/ipc:../../out/rk3568/distributedschedule/samgr_standard:../../out/rk3568/security/access_token:../../out/rk3568/communication/dsoftbus:../../out/rk3568/startup/startup_l2/:../../out/rk3568/security/huks/:../../out/rk3568/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/thirdparty/zlib:../../out/rk3568/lib.unstripped/commonlibrary/c_utils:../../out/rk3568/lib.unstripped/systemabilitymgr/samgr:../../out/rk3568/clang_x64/arkcompiler/ets_runtime --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --ark-tool=../../out/rk3568/arkcompiler/ets_runtime/ark_js_vm --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-aot --ark-arch=aarch64 --ark-arch-root=aarch64 > $log_dir/test262_${time_stamp}_aot_arm64.log
    # asmint
    echo 123456 | sudo -S python3 test262/run_test262.py --es2021 all --threads 128 --timeout 180000 --libs-dir=../../out/rk3568/arkcompiler/ets_runtime/:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos/:../../out/rk3568/utils/utils_base/:../../out/rk3568/thirdparty/icu:../../out/rk3568/thirdparty/zlib:../../out/rk3568/securec/thirdparty_bounds_checking_function:../../out/rk3568/hiviewdfx/faultloggerd:../../out/rk3568/thirdparty/bounds_checking_function:../../out/rk3568/hiviewdfx/hilog_native:../../out/rk3568/startup/init:../../out/rk3568/thirdparty/cjson:../../out/rk3568/lib.unstripped/common/dsoftbus:../../out/rk3568/security/selinux:../../out/rk3568/hiviewdfx/hitrace_native/:../../out/rk3568/communication/ipc:../../out/rk3568/distributedschedule/samgr_standard:../../out/rk3568/security/access_token:../../out/rk3568/communication/dsoftbus:../../out/rk3568/startup/startup_l2/:../../out/rk3568/security/huks/:../../out/rk3568/clang_x64/thirdparty/icu:../../out/rk3568/clang_x64/thirdparty/zlib:../../out/rk3568/lib.unstripped/commonlibrary/c_utils:../../out/rk3568/clang_x64/arkcompiler/ets_runtime --ark-frontend-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/es2abc --ark-tool=../../out/rk3568/arkcompiler/ets_runtime/ark_js_vm --ark-aot-tool=../../out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_aot_compiler --merge-abc-binary=../../out/rk3568/clang_x64/arkcompiler/ets_frontend/merge_abc --ark-frontend=es2panda --ark-arch=aarch64 --ark-arch-root=aarch64 > $log_dir/test262_${time_stamp}_asmint_arm64.log
    cd $source_dir
    echo "time_stamp: $(date +%H:%M:%S)"
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_aot_arm64 --all --product rk3568 -f es2abc --timeout 2400 --arm64 &> $log_dir/benchmark_${time_stamp}_aot_arm64.log
    echo "time_stamp: $(date +%H:%M:%S)"
    python arkcompiler/ets_runtime/test/runtest.py $test_dir/benchmark_octane/lib_asmint_arm64 --all --product rk3568 -f es2abc --tool asmint --timeout 2400 --arm64 &> $log_dir/benchmark_${time_stamp}_asmint_arm64.log
    echo "time_stamp: $(date +%H:%M:%S)"
}

function run_5000class()
{
    cd $test_dir/5000Classes
    ./runAotCommand.sh import5000.js &> $test_dir/aot_5000class.log 
    ./runAotCommand.sh import5000_new.js &> $test_dir/aot_5000class_new.log
}

function run_sigle_hap_arm64()
{
    #Run hap with type
    cd $hap_dir
    python3 $source_dir/arkcompiler/ets_runtime/test/runtest.py $1.hap --arm64 -p r --bt -f es2abc &>> $log_dir/haptest_${time_stamp}_aot_arm64.log
    file_size_an=0
    file_size_abc=0
    file_size_an=$(stat --format=%s $hap_dir/$1.aot/ets/modules.an)
    file_size_abc=$(stat --format=%s $hap_dir/$1.aot/ets/modules.abc)
    if [ -z "$file_size_an" ]; then
        file_size_an=0
    else
        file_size_an=$(expr $file_size_an / 1024)
    fi
    file_size_abc=$(expr $file_size_abc / 1024)
    echo "test-type: $1.aot/ets/modules.abc  abc_size:  $file_size_abc KB an_size: $file_size_an KB" >> $log_dir/haptest_${time_stamp}_aot_arm64.log

    #Run hap with no-type
    python3 $source_dir/arkcompiler/ets_runtime/test/runtest.py $1.hap --arm64 -p r --bt --aot-args="--enable-type-lowering=false" &>> $log_dir/haptest_${time_stamp}_notype_aot_arm64.log
    file_size_an=$(stat --format=%s $hap_dir/$1.aot/ets/modules.an)
    file_size_abc=$(stat --format=%s $hap_dir/$1.aot/ets/modules.abc)
    if [ -z "$file_size_an" ]; then
        file_size_an=0
    else
        file_size_an=$(expr $file_size_an / 1024)
    fi
    file_size_abc=$(expr $file_size_abc / 1024)
    echo "test-notype: $1.aot/ets/modules.abc  abc_size:  $file_size_abc KB an_size: $file_size_an KB" >> $log_dir/haptest_${time_stamp}_notype_aot_arm64.log
}

function run_hap_arm64()
{
    cd $source_dir
    python3 $source_dir/arkcompiler/ets_runtime/test/runtest.py -p r test/aottest/add --npm
    cd $test_dir
    run_sigle_hap_arm64 "com.huawei.dy"
    run_sigle_hap_arm64 "com.huawei.tb"
    run_sigle_hap_arm64 "com.huawei.wx"
    run_sigle_hap_arm64 "com.huawei.rili13pc"
    run_sigle_hap_arm64 "com.huawei.rili13ph"
}

function reset_code()
{
    cd $source_dir/arkcompiler/ets_runtime
    git reset --hard HEAD
    cd $source_dir/arkcompiler/ets_frontend
    git reset --hard HEAD
    cd $source_dir/arkcompiler/runtime_core
    git reset --hard HEAD
    cd /mnt/data/zwx1072417/ArkDaily/openharmony/code/foundation/bundlemanager/bundle_framework/services/bundlemgr
    git reset --hard HEAD
}

function get_test262_result()
{
    cd $test_dir
    tail -n 30 $log_dir/test262_${time_stamp}_$1.log >> summary_$1.txt
    sed -i 's/PASS test262.*//g' $log_dir/test262_${time_stamp}_$1.log
    sed -i '/^$/d' $log_dir/test262_${time_stamp}_$1.log
    
    ran=$(grep "Ran [0-9]\+" summary_$1.txt | awk -F ' ' '{print $2}')
    sed -i "s#run_$1: 0#Ran: $ran#" test_report.html
    
    passed=$(grep "[0-9]\+ passed" summary_$1.txt | awk -F ' ' '{print $1}')
    sed -i "s#passed_$1: 0#Passed: $passed#" test_report.html
    
    failed=$(grep "[0-9]\+ failed" summary_$1.txt | awk -F ' ' '{print $1}')
    sed -i "s#failed_$1: 0#Failed: $failed#" test_report.html
    
    time=$(grep "used time.*[0-9:.]\+" summary_$1.txt | awk -F ' ' '{print $4}')
    sed -i "s#used_time_$1: 0#Used Time: $time#" test_report.html

    rm -rf summary_$1.txt
}

function get_5000class_result_string()
{
    ret=$(grep -i "Segmentation fault" $1)
    if [ -n "$ret" ]; then
        result="$2: Segmentation fault"
    else
        result=$(cat $1)
    fi
    
    echo $result
}

function get_5000class_result()
{
    cd $test_dir
    build_5000class=$(get_5000class_result_string 5000class.txt import5000.js)
    sed -i "s#5000classes_time_asmint#$build_5000class#" test_report.html
    build_5000class=$(get_5000class_result_string 5000class_new.txt import5000_new.js)
    sed -i "s#5000classes_new_time_asmint#$build_5000class#" test_report.html

    build_5000class=$(get_5000class_result_string aot_5000class.log import5000.js)
    sed -i "s/5000classes_time_aot/$build_5000class/" test_report.html

    build_5000class=$(get_5000class_result_string aot_5000class_new.log import5000_new.js)
    sed -i "s/5000classes_new_time_aot/$build_5000class/" test_report.html
}

function get_benchmark_asm_score()
{
    asm_score=$(grep "$1.*[0-9]\+" $log_dir/asm_benchmark_x64.log | awk -F ' ' '{print $3}' | head -1)
    sed -i "s#$1_score_asm#$asm_score#" build_benchmark_table.wip
}

function get_benchmark_score()
{
    old_score=$(grep "$2.*[0-9]\+" $3 | awk -F ' ' '{print $3}' | head -1)
    new_score=$(grep "$2.*[0-9]\+" $4 | awk -F ' ' '{print $3}' | head -1)
    percent=""
    if [ -n "$old_score" -a -n "$new_score" ]; then
        percent=$(python -c "print(int(100*($new_score-$old_score)/$old_score))")
    fi
    if [ -z "$old_score" ]; then
        old_score="FAIL"
    fi
    if [ -z "$new_score" ]; then
        new_score="FAIL"
    fi
    sed -i "s#$2_score_$1#$new_score#" build_benchmark_table.wip
}

function get_benchmark_result_old_new()
{
    # get last log
    old=""
    new=""
    for log in $(ls $log_dir/benchmark_*_$1.log)
    do
        old=$new
        new=$log
        if [ "$new" == "$log_dir/benchmark_${time_stamp}_$1.log" ]; then
            break
        fi
    done

    new="$log_dir/benchmark_${time_stamp}_$1.log"
    if [ -z "$old" ]; then
        old=$new
    fi

    get_benchmark_score $1 "Crypto" $old $new
    get_benchmark_score $1 "EarleyBoyer" $old $new
    get_benchmark_score $1 "RayTrace" $old $new
    get_benchmark_score $1 "Splay" $old $new
    get_benchmark_score $1 "SplayLatency" $old $new
    get_benchmark_score $1 "Box2D" $old $new
    get_benchmark_score $1 "NavierStokes" $old $new
    get_benchmark_score $1 "Richards" $old $new
    get_benchmark_score $1 "DeltaBlue" $old $new
    get_benchmark_score $1 "RegExp" $old $new
    get_benchmark_score $1 "Mandreel" $old $new
    get_benchmark_score $1 "MandreelLatency" $old $new
    get_benchmark_score $1 "PdfJS" $old $new
    get_benchmark_score $1 "Typescript" $old $new
}

function get_benchmark_ts_result_old_new()
{
    # get last log
    old=""
    new=""
    for log in $(ls $log_dir/benchmark_ts_*_$1.log)
    do
        old=$new
        new=$log
        if [ "$new" == "$log_dir/benchmark_ts_${time_stamp}_$1.log" ]; then
            break
        fi
    done

    new="$log_dir/benchmark_ts_${time_stamp}_$1.log"
    if [ -z "$old" ]; then
        old=$new
    fi

    get_benchmark_ts_score "Air" $old $new $1
    get_benchmark_ts_score "deltablue" $old $new $1
    get_benchmark_ts_score "raytrace" $old $new $1
    get_benchmark_ts_score "richards" $old $new $1
    get_benchmark_ts_score "UniPoker" $old $new $1
    # get_benchmark_ts_score "WSL" $old $new $1
    get_benchmark_ts_score "cocos" $old $new $1
    get_benchmark_ts_score "cocos_airplan" $old $new $1
    get_benchmark_ts_score "forlooper" $old $new $1
    get_benchmark_ts_score "himovie" $old $new $1
    get_benchmark_ts_score "loop" $old $new $1
    get_benchmark_ts_score "no-body" $old $new $1
    get_benchmark_ts_score "objaccess" $old $new $1
    get_benchmark_ts_score "splay" $old $new $1
}

function get_benchmark_ts_score()
{
    old_score=$(grep "$1_total.*[0-9]\+" $2 | awk -F ' ' '{print $3}' | head -1)
    new_score=$(grep "$1_total.*[0-9]\+" $3 | awk -F ' ' '{print $3}' | head -1)
    percent=""
    if [ -n "$old_score" -a -n "$new_score" ]; then
        percent=$(python -c "print(int(100*($old_score-$new_score)/$new_score))")
        echo $percent
    fi
    if [ -z "$new_score" ];then
        sed -i "s#$1_$4#FAIL#" build_benchmark_ts_table.wip
    else
        sed -i "s#$1_$4#$new_score#" build_benchmark_ts_table.wip
    fi
}

function get_benchmark_ts_result()
{
    cd $test_dir
    cp build_benchmark_ts_table.template build_benchmark_ts_table.wip

    get_benchmark_ts_result_old_new "v8_x64"
    get_benchmark_ts_result_old_new "asmint_x64"
    get_benchmark_ts_result_old_new "aot_type_x64"
    get_benchmark_ts_result_old_new "aot_no_type_x64"
    get_benchmark_ts_result_old_new "es2abc_asmint_x64"
    get_benchmark_ts_result_old_new "es2abc_aot_type_x64"
    get_benchmark_ts_result_old_new "es2abc_aot_no_type_x64"


    cat build_benchmark_ts_table.wip >> test_report.html
    rm -rf build_benchmark_ts_table.wip
}

function get_benchmark_result()
{
    cd $test_dir
    cp build_benchmark_table.template build_benchmark_table.wip

    get_benchmark_result_old_new "asmint_x64"
    get_benchmark_result_old_new "aot_x64"
    get_benchmark_result_old_new "asmint_arm64"
    get_benchmark_result_old_new "aot_arm64"
    get_benchmark_result_old_new "es2abc_aot_no_type"

    get_benchmark_result_old_new "es2abc"
    get_benchmark_result_old_new "has_opt_v8"
    get_benchmark_result_old_new "no_opt_v8"
    get_benchmark_result_old_new "qjs"
    get_benchmark_result_old_new "hermes"
    get_benchmark_result_old_new "int"
    get_benchmark_result_old_new "pgo"

    cat build_benchmark_table.wip >> test_report.html
    rm -rf build_benchmark_table.wip
}

function get_hap_score()
{
    file_size_abc=0
    file_size_an=0
    file_size_abc=$(grep "test-type: $1" $log_dir/haptest_${time_stamp}_aot_arm64.log | awk -F ' ' '{print $4}')
    file_size_an=$(grep "test-type: $1" $log_dir/haptest_${time_stamp}_aot_arm64.log | awk -F ' ' '{print $7}')
    if [ $file_size_an -gt $file_size_abc ]; then
        file_size_an=$(python -c "print('%.1f' % ($file_size_an/1024))")
        sed -i "s#$1_type_an#$file_size_an#" build_hap_table.wip
    else
        sed -i "s#$1_type_an#FAIL#" build_hap_table.wip
    fi

    file_size_an=$(grep "test-notype: $1" $log_dir/haptest_${time_stamp}_notype_aot_arm64.log | awk -F ' ' '{print $7}')
    if [ $file_size_an -gt $file_size_abc ]; then
        file_size_an=$(python -c "print('%.1f' % ($file_size_an/1024))")
        sed -i "s#$1_notype_an#$file_size_an#" build_hap_table.wip
    else
        sed -i "s#$1_notype_an#FAIL#" build_hap_table.wip
    fi

    file_size_abc=$(python -c "print('%.1f' % ($file_size_abc/1024))")
    sed -i "s#$1_abc#$file_size_abc#" build_hap_table.wip
}

function get_hap_result()
{
    cd $test_dir
    cp build_hap_table.template build_hap_table.wip

    get_hap_score "com.huawei.dy"
    get_hap_score "com.huawei.tb"
    get_hap_score "com.huawei.wx"
    get_hap_score "com.huawei.rili13pc"
    get_hap_score "com.huawei.rili13ph"

    cat build_hap_table.wip >> test_report.html
    rm -rf build_hap_table.wip
}

function packed_file()
{
    mkdir $log_dir/test262_${time_stamp} $log_dir/benchmark_${time_stamp} $log_dir/benchmark_ts_${time_stamp} $log_dir/haptest_${time_stamp} $log_dir/UT_${time_stamp}

    cd $log_dir
    cp $log_dir/test262_${time_stamp}_*.log $log_dir/test262_${time_stamp}
    tar zcvf $log_dir/test262_${time_stamp}.tar.gz test262_${time_stamp}

    cp $log_dir/benchmark_${time_stamp}_*.log $log_dir/benchmark_${time_stamp}
    tar zcvf $log_dir/benchmark_${time_stamp}.tar.gz benchmark_${time_stamp}

    cp $log_dir/benchmark_ts_${time_stamp}_*.log $log_dir/benchmark_ts_${time_stamp}
    tar zcvf $log_dir/benchmark_ts_${time_stamp}.tar.gz benchmark_ts_${time_stamp}

    cp $log_dir/haptest_${time_stamp}_*.log $log_dir/haptest_${time_stamp}
    tar zcvf $log_dir/haptest_${time_stamp}.tar.gz haptest_${time_stamp}

    tar zcvf $log_dir/run_test_${time_stamp}.tar.gz run_test_${time_stamp}.log
    
    cp $source_dir/UT_${time_stamp}_*.log $log_dir/UT_${time_stamp}
    tar zcvf $log_dir/UT_${time_stamp}.tar.gz UT_${time_stamp}

    cd $test_dir
    tar zcvf $log_dir/all_haptest/hap_test_${time_stamp}.tar.gz hap_test
}

function run_test262_es2015(){
  test262_es2015_hour=0
  test262_es2015_minute=0
  test262_es2015_second=0
  test262_es2015_now=`date +'%Y-%m-%d %H:%M:%S'`
  test262_es2015_start_time=$(date --date="$test262_es2015_now" +%s);
  
  echo 123456 | sudo -S chmod -R 777 $source_dir/third_party/jerryscript/
  echo 123456 | sudo -S rm -rf $source_dir/third_party/jerryscript/build
  echo 123456 | sudo -S rm -rf $source_dir/third_party/jerryscript/tests/test262
  
  echo 123456 | sudo -S cp $test_dir/jerry_test262/test262-es6.patch $source_dir/third_party/jerryscript/tests
  echo 123456 | sudo -S cp $test_dir/jerry_test262/jerry_test262.patch $source_dir/third_party/jerryscript/
  cd $source_dir/third_party/jerryscript
  git apply jerry_test262.patch
  python ./tools/run-tests.py --test262-es2015 -q
  cp ./build/tests/test262_tests_es2015/local/bin/test262.report $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '$d' $log_dir/test262_${time_stamp}_test262_es2015.log
  #裁剪.log文件格式
  sed -i '/Excluded: /d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/output/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/Exception/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/errors/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/Error/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/unknow/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i '/^$/d' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i 's/=//g' $log_dir/test262_${time_stamp}_test262_es2015.log
  sed -i 's/^ //1' $log_dir/test262_${time_stamp}_test262_es2015.log  
  
  test262_es2015_now=`date +'%Y-%m-%d %H:%M:%S'`
  test262_es2015_end_time=$(date --date="$test262_es2015_now" +%s);
  #echo "used time:"$((end_time-start_time))"s"
  test262_es2015_second=$((test262_es2015_end_time-test262_es2015_start_time))
  test262_es2015_minute=$((test262_es2015_second/60))
  test262_es2015_second=$((test262_es2015_second-60*test262_es2015_minute))


  echo "test262_es2015_hour = $test262_es2015_hour" >> $log_dir/test262_${time_stamp}_test262_es2015.log 
  echo "test262_es2015_minute = $test262_es2015_minute" >> $log_dir/test262_${time_stamp}_test262_es2015.log
  echo "test262_es2015_second = $test262_es2015_second" >> $log_dir/test262_${time_stamp}_test262_es2015.log 
}

function get_test262_es2015(){

  test262_es2015_ran=0
  test262_es2015_passed=0
  test262_es2015_failed=0
  
  test262_es2015_ran=`grep -nw "Ran" $log_dir/test262_${time_stamp}_test262_es2015.log| awk '{printf $3}'`
  test262_es2015_isAllPassed=`grep -nw "succeeded" $log_dir/test262_${time_stamp}_test262_es2015.log | awk '{printf $4}'`

  if [ "$test262_es2015_isAllPassed" == "succeeded" ]
  then
      test262_es2015_passed=$test262_es2015_ran
      test262_es2015_failed=0
  else
      test262_es2015_passed=`grep -n "Passed" $log_dir/test262_${time_stamp}_test262_es2015.log | awk '{print $3}'`
      test262_es2015_failed=`grep -n "\- Failed" $log_dir/test262_${time_stamp}_test262_es2015.log | awk '{print $3}'`
  fi

  sed -i "s#run_test262_es2015: 0#Ran: $test262_es2015_ran#" $test_dir/test_report.html
  sed -i "s#passed_test262_es2015: 0#Passed: $test262_es2015_passed#" $test_dir/test_report.html
  sed -i "s#failed_test262_es2015: 0#Failed: $test262_es2015_failed#" $test_dir/test_report.html
  
  test262_es2015_hour=`grep -nw "test262_es2015_hour" $log_dir/test262_${time_stamp}_test262_es2015.log | awk -F= '{printf $2}'`
  test262_es2015_minute=`grep -nw "test262_es2015_minute" $log_dir/test262_${time_stamp}_test262_es2015.log | awk -F= '{printf $2}'`
  test262_es2015_second=`grep -nw "test262_es2015_second" $log_dir/test262_${time_stamp}_test262_es2015.log | awk -F= '{printf $2}'`  
  sed -i "s#used_time_test262_es2015: 0#Used Time: `echo $test262_es2015_hour|awk '{printf("%02d\n",$0)}'`:`echo $test262_es2015_minute|awk '{printf("%02d\n",$0)}'`:`echo $test262_es2015_second|awk '{printf("%02d\n",$0)}'`#"  $test_dir/test_report.html
}

function getworkload()
{
    cp $test_dir/workload.html $test_dir/workload1.html
    lineName="/mnt/data/zwx1072417/ArkDaily/shell/1.log"
    for item in "${my_list[@]}"; do
        get_workload_result $item
    done

}

function get_workload_result()
{   
    # swift="/mnt/data/zwx1072417/ArkDaily/log/workload_swift.log"
    pgo="/mnt/data/zwx1072417/ArkDaily/log/workload_pgo.log"
    lineName="/mnt/data/zwx1072417/ArkDaily/shell/1.log"
    for item2 in "${my_list[@]}"; do
        echo $item2
        # temp="_swift"
        temp="${item2}$temp"
        echo $temp
        # get_workload_score $1 "$item2" $swift $pgo
        get_workload_score $1 "$item2" $pgo
    done
}

function get_workload_score()
{
    b="FAIL"
    pgo="/mnt/data/zwx1072417/ArkDaily/log/workload_pgo.log"
    for item2 in "${my_list[@]}"; do
        echo $item2
        # get_workload_score $1 "$item2"  $pgo

        pgo_score=$(grep "$item2*" $pgo | awk -F'\t' '{print $2}'| head -1)
        echo $pgo_score
        if [ -z "$pgo_score" ]; then
            pgo_score="FAIL"
            b="FAIL"
        fi
        sed -i "s#\b${item2}_pgo\b#$pgo_score#" /mnt/data/zwx1072417/ArkDaily/shell/workload1.html


    done
}

function delete_file()
{
    rm -rf $log_dir/test262_${time_stamp}
    rm -rf $log_dir/test262_${time_stamp}.tar.gz
    rm -rf $log_dir/run_test_${time_stamp}.tar.gz
    rm -rf $log_dir/benchmark_${time_stamp}
    rm -rf $log_dir/benchmark_${time_stamp}.tar.gz
    rm -rf $log_dir/benchmark_ts_${time_stamp}
    rm -rf $log_dir/benchmark_ts_${time_stamp}.tar.gz
    rm -rf $log_dir/haptest_${time_stamp}
    rm -rf $log_dir/haptest_${time_stamp}.tar.gz
    rm -rf $log_dir/UT_${time_stamp}
    rm -rf $log_dir/UT_${time_stamp}.tar.gz
}

# function send_mail()
# {
#     cd $test_dir
#     # MAX: 10MB
#     MAX_FILE_SIZE=10485760
#     file_size_run_test=0
#     file_size_test262=0
#     file_size_benchmark=0
#     file_size_haptest=0
#     file_size_benchmark_ts=0
#     file_size_UT=0
#     packed_file
#     file_size_run_test=$(stat --format=%s $log_dir/run_test_${time_stamp}.tar.gz)
#     file_size_test262=$(stat --format=%s $log_dir/test262_${time_stamp}.tar.gz)
#     file_size_UT=$(stat --format=%s $log_dir/UT_${time_stamp}.tar.gz)
#     file_size_benchmark=$(stat --format=%s $log_dir/benchmark_${time_stamp}.tar.gz)
#     file_size_haptest=$(stat --format=%s $log_dir/haptest_${time_stamp}.tar.gz)
#     file_size_benchmark_ts=$(stat --format=%s $log_dir/benchmark_ts_${time_stamp}.tar.gz)

#     file_size=$(expr $file_size_run_test + $file_size_test262 + $file_size_benchmark + $file_size_haptest + $file_size_benchmark_ts)
#     if [ $file_size -gt $MAX_FILE_SIZE ]; then
#         cat $test_dir/test_report.html | mutt -s "【蓝区master】ark test report(log too large) - $time_stamp" -e "set content_type=text/html" -- $(cat recipients_maxiaodong)
#     else
#         cat $test_dir/test_report.html | mutt -s "【蓝区master】ark test report - $time_stamp" -e "set content_type=text/html" -a $log_dir/run_test_${time_stamp}.tar.gz $log_dir/test262_${time_stamp}.tar.gz $log_dir/benchmark_${time_stamp}.tar.gz $log_dir/haptest_${time_stamp}.tar.gz $log_dir/benchmark_ts_${time_stamp}.tar.gz -- $(cat recipients_maxiaodong)
#     fi
#     # delete_file
# }

#######################################################################################################################
set -x
time_stamp=$(date +%m%d%H%M)
if [ -n "$1" ]; then
    time_stamp=$1
fi
filename="/mnt/data/zwx1072417/ArkDaily/shell/1.log"
declare -a my_list=()
# 读取文件并将每一行存储到my_list数组中
readarray -t my_list < "$filename"
for item in "${my_list[@]}"; do
    echo "每一行是: $item" 
done
hap_dir=/mnt/data/zwx1072417/ArkDaily/shell/hap_test/
test_dir=/mnt/data/zwx1072417/ArkDaily/shell
log_dir=/mnt/data/zwx1072417/ArkDaily/log
source_dir=/mnt/data/zwx1072417/ArkDaily/openharmony/code
rm -rf $test_dir/test_report.html

# sudo your_command_here
# set environment variables
export PATH=/mnt/data/zwx1072417/ArkDaily/tools/bin:/tools/bin:$source_dir/prebuilts/build-tools/common/nodejs/node-v12.18.4-linux-x64/bin:$PATH

# export PATH3=/usr/bin/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$source_dir/out/rk3568/clang_x64/ark/ark:$source_dir/out/rk3568/clang_x64/ark/ark_js_runtime:$source_dir/out/rk3568/clang_x64/thirdparty/icu:$source_dir/out/rk3568/clang_x64/thirdparty/zlib:$source_dir/out/rk3568/arkcompiler/ets_runtime/ark_js_vm:$source_dir/out/rk3568/communication/ipc:$source_dir/out/rk3568/lib.unstripped/commonlibrary/c_utils:$source_dir/out/rk3568/lib.unstripped/systemabilitymgr/samgr:$source_dir/out/rk3568/hiviewdfx/faultloggerd:$source_dir/out/rk3568/startup/init:
export LIBRARY_PATH=$source_dir/out/rk3568/clang_x64/ark/ark:$source_dir/out/rk3568/clang_x64/ark/ark_js_runtime:$source_dir/out/rk3568/clang_x64/thirdparty/icu:$source_dir/out/rk3568/clang_x64/thirdparty/zlib
cat $test_dir/header.preset >> $test_dir/test_report.html

# only report test for debug use
if [ -z "$1" ]; then
    rm -rf $log_dir
    mkdir -p $log_dir
    run_test_sync_code
	# if [ -f "$test_dir/runtest.py" ]; then
	# 	cp -f $test_dir/runtest.py $source_dir/arkcompiler/ets_runtime/test
	# fi
    touch $log_dir/test262_${time_stamp}_asmint_release.log $log_dir/test262_${time_stamp}_aot_release.log $log_dir/test262_${time_stamp}_asmint_debug.log $log_dir/test262_${time_stamp}_aot_debug.log $log_dir/test262_${time_stamp}_asmint_arm64.log $log_dir/test262_${time_stamp}_aot_arm64.log $log_dir/benchmark_${time_stamp}_aot_x64.log $log_dir/benchmark_${time_stamp}_aot_arm64.log
    # reset_code
    run_test_arm64
    run_test_debug
    # do not move up, for benchmark use afterwards
    run_test_release
    run_test262_es2015
    echo "time_stamp: $(date +%H:%M:%S)"
    run_hap_arm64
    echo "time_stamp: $(date +%H:%M:%S)"
    reset_code
fi
get_current_commit_id
get_UT_result
cat $test_dir/build_summary_table.template >> $test_dir/test_report.html
get_test262_result cint_release
get_test262_result cint_debug
get_test262_result cint_es2panda_release
get_test262_result asmint_release
get_test262_result aot_release
get_test262_result asmint_debug
get_test262_result aot_debug
get_test262_result asmint_arm64
get_test262_result aot_arm64
get_test262_es2015
get_benchmark_result
get_benchmark_ts_result


# get_workload_result
# get_workload_score
# getworkload

# cat $test_dir/workload1.html >> $test_dir/test_report.html
# rm $test_dir/workload1.html
cat $test_dir/tail.preset >> $test_dir/test_report.html
set +x
